<?php

class Video extends BaseVideo
{
	
  public function delete(PropelPDO $con = null)
  {
  	 
  	 ///Удаляем файлы
  	 if($this->getVideoPath()!='')
  	 {
	  	$fname = sfConfig::get('sf_upload_dir').'/users/video/'.$this->getVideoPath();
	    $fthname = sfConfig::get('sf_upload_dir').'/users/video/'.$this->getVideoPath().'.flv';
	    $_fthname = sfConfig::get('sf_upload_dir').'/users/video/thumbnail/'.$this->getVideoPath().'.jpeg';
	
	    @unlink($fname);
	    @unlink($fthname);
	    @unlink($_fthname);
  	 }
  	 
  	 parent::delete();
  }
  
  
  
  
   public function save(PropelPDO $con = null)
	{
		parent::save();

		////Задаем флаг присутствия видео
		$pf = $this->getsfGuardUser();
		$c = new Criteria();
		$c->add(VideoPeer::USER_ID,$pf->getId());
		//$c->add(VideoPeer::PUB,1);
		$cnt = VideoPeer::doCount($c);
		if($cnt>0)
		{
			$pf->setHaveVideo(true);
			$pf->save();
		}
		////

	}
	
	
}
